﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Windows;

namespace DarkLight.Model
{
    [DataContract]
    public abstract class Trajectory : SpaceObject, IOrientation
    {
        #region Public Members
        /// <summary>
        /// Orientation in the local space
        /// </summary>
        [DataMember]
        [Required(ErrorMessage="Value can't be null.")]
        public Rotation Orientation
        {
            get { return _orientation; }
            set
            {
                if (!object.ReferenceEquals(_orientation, value))
                {
                    RaisePropertyChanging("Orientation");
                    _orientation = value;
                    RaisePropertyChanged("Orientation");
                }
            }
        }
        private Rotation _orientation;

        /// <summary>
        /// Position in radius on the trajectory
        /// </summary>
        [DataMember]
        [Range(0.0, 2.0 * Math.PI, ErrorMessage = "Value must be between 0 and 2*Pi.")]
        public float TrajectoryRotation
        {
            get { return _trajectoryRotation; }
            set 
            {
                if (_trajectoryRotation != value)
                {
                    RaisePropertyChanging("TrajectoryRotation");
                    _trajectoryRotation = value;
                    RaisePropertyChanged("TrajectoryRotation");
                }
            }
        }
        private float _trajectoryRotation;

        /// <summary>
        /// Eccentricity of the trajectory
        /// </summary>
        [DataMember]
        [Range(0.0, 0.999, ErrorMessage="Value must be between 0 and 1.")]
        public float TrajectoryEccentricity
        {
            get { return _trajectoryEccentricity; }
            set
            {
                if (_trajectoryEccentricity != value)
                {
                    RaisePropertyChanging("TrajectoryEccentricity");
                    _trajectoryEccentricity = value;
                    RaisePropertyChanged("TrajectoryEccentricity");
                }
            }
        }
        private float _trajectoryEccentricity;

        /// <summary>
        /// Is the trajectory focus reverted
        /// </summary>
        [DataMember]
        public bool IsTrajectoryFocusReverted
        {
            get { return _isTrajectoryFocusReverted; }
            set
            {
                if (_isTrajectoryFocusReverted != value)
                {
                    RaisePropertyChanging("IsTrajectoryFocusReverted");
                    _isTrajectoryFocusReverted = value;
                    RaisePropertyChanged("IsTrajectoryFocusReverted");
                }
            }
        }
        private bool _isTrajectoryFocusReverted;
        #endregion
    }
}
